﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompositePattern.GeneralDemoTwo
{
    public abstract class Corp
    {
        private string name = "";
        private string position = "";
        private int salary = 0;
        private Corp parent = null; //父節點

        public Corp(string name, string position, int salary)
        {
            this.name = name;
            this.position = position;
            this.salary = salary;
        }

        public string getInfo()
        {
            string info = string.Empty;
            info = "name:" + this.name + Environment.NewLine;
            info += "position:" + this.position + Environment.NewLine;//职位
            info += "salary:" + this.salary + Environment.NewLine; //薪水
            return info;
        }

        /// <summary>
        /// 設置父節點
        /// </summary>
        /// <param name="_parent"></param>
        public void setParent(Corp _parent) {
            this.parent = _parent;
        }

        /// <summary>
        /// 得到父節點
        /// </summary>
        /// <returns></returns>
        public Corp getParent()
        {
            return this.parent;
        }
    }
}
